﻿using Mall.Application;
using Mall.Core;
using Mall.Core.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Mall.Web.Entry.Controllers
{
    [Authorize]
    public class ProductController : Controller
    {
        #region Field
        private readonly IProductService _productService;
        #endregion

        #region Ctor
        public ProductController(IProductService productService)
        {
            _productService = productService;
        }
        #endregion

        #region Index
        public IActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public IActionResult Index(ProductDtoInput input)
        {
            var page = _productService.GetPagedList(input);
            return Json(new LayuiResult<ProductDtoOutput> {
                Code = "0", Msg = "", Data = page.Items, Count = page.TotalCount 
            });
        }
        #endregion

        #region Add
        public ActionResult Create() {
            return View();
        }
        [HttpPost]
        public ActionResult Create(Product product)
        {
            
            return View();
        }
        #endregion

        #region Edit

        #endregion

        #region Del

        #endregion
    }
}
